home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pas_all.zip / TI310.ASC < prev    next >
Text File  |  1992-08-12  |  3KB  |  133 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.   PRODUCT : TURBO PASCAL                               NUMBER : 310
  10.   VERSION : 3.0xx
  11.        OS : PC-DOS, MS-DOS
  12.      DATE : June 19, 1986                                PAGE : 1/2
  13.     TITLE : FILE ATTRIBUTES, SETTING & GETTING
  14.  
  15.  
  16.  
  17.  
  18.   Use the following routines to set and get a particular file's
  19.   attribute from within a Turbo Pascal program.
  20.  
  21.   type
  22.     AnyString = string[80];                { Generic string type }
  23.     Registers = record
  24.       case Byte of
  25.         1 : (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: integer);
  26.         2 : (AL, AH, BL, BH, CL, CH, DL, DH: byte);
  27.     end;
  28.  
  29.   function SetFileAttribute(FileName : AnyString;
  30.                            Attribute : integer) : integer;
  31.   { Sets a particular file's attribute byte - returns error code:
  32.  
  33.     0 - no error
  34.     2 - file not found
  35.     3 - path not found
  36.     5 - access denied
  37.  
  38.   }
  39.   var Reg : Registers;
  40.   begin
  41.     Reg.AH := $43;
  42.     Reg.AL := $01;
  43.     Reg.CX := Attribute;
  44.     FileName := FileName + #0;
  45.                     { Make the file name an ASCIIZ string }
  46.     Reg.DS := Seg(FileName);
  47.     Reg.DX := Succ(Ofs(FileName));
  48.                     { The offset of the first char in the name }
  49.     MsDos(Reg);
  50.     if not (Reg.AX in [2, 3, 5]) then
  51.       Reg.AX := 0;
  52.     SetFileAttribute := Reg.AX;
  53.   end; { SetFileAttribute }
  54.  
  55.   function GetFileAttribute(FileName : AnyString;
  56.                        var Attribute : integer) : integer;
  57.   { Gets a particular file's attribute byte - returns error code:
  58.  
  59.     0 - no error
  60.     2 - file not found
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.   PRODUCT : TURBO PASCAL                               NUMBER : 310
  76.   VERSION : 3.0xx
  77.        OS : PC-DOS, MS-DOS
  78.      DATE : June 19, 1986                                PAGE : 2/2
  79.     TITLE : FILE ATTRIBUTES, SETTING & GETTING
  80.  
  81.  
  82.  
  83.  
  84.     3 - path not found
  85.     5 - access denied
  86.  
  87.   }
  88.   var Reg : Registers;
  89.   begin
  90.     Reg.AH := $43;
  91.     Reg.AL := $00;
  92.     FileName := FileName + #0;
  93.                     { Make the file name an ASCIIZ string }
  94.     Reg.DS := Seg(FileName);
  95.     Reg.DX := Succ(Ofs(FileName));
  96.                     { The offset of the first char in the name }
  97.     MsDos(Reg);
  98.     Attribute := Reg.CX;
  99.     if not (Reg.AX in [2, 3, 5]) then
  100.       Reg.AX := 0;
  101.     GetFileAttribute := Reg.AX;
  102.   end; { GetFileAttribute }
  103.  
  104.   DISCLAIMER: You have the right to use this technical information
  105.   subject to the terms of the No-Nonsense License Statement that
  106.   you received with the Borland product to which this information
  107.   pertains.
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.